<template>
	<view>
		<view class="">
			
			<uv-alert type="warning" :show-icon="true" description='请阅读领养合同'> </uv-alert>
		</view>
		<view class="" style="font-size: 28rpx;font-weight: 700;padding: 20rpx;">
			{{name.jsonViewData.name}}
		</view>
		<view class="" style="padding: 20rpx;border-bottom: 1rpx solid #e8e8e8;font-size: 26rpx;color: #666;">
			领养门店：{{info.businessName}}
		</view>
		<!-- <view class="" style="padding: 20rpx;border-bottom: 1rpx solid #e8e8e8;font-size: 26rpx;color: #666;">
			联系号码：{{info.businessMobile}}
		</view> -->
		<view class="" style="padding: 20rpx;border-bottom: 1rpx solid #e8e8e8;font-size: 26rpx;color: #666;">
			具体地址：{{ info.businessAddress }} 
		</view>
		
		<view class="" style="padding-bottom: 120rpx;">
			<image style="width: 750rpx;" :src="srcimage" mode="widthFix" @click="btn(srcimage)"></image>
		</view>
		
		<view class="" style="position: fixed;bottom: 0;left: 0;right: 0;display: flex;justify-content: center;align-items: center;background-color: #fff;flex-direction: column;">
			<!-- <view class="" style="width: 600rpx;height: 80rpx;background-color: deepskyblue;border-radius: 40rpx;text-align: center;line-height: 80rpx;color: #fff;" @click="goPath()">
				查看合同
			</view> -->
			<view v-if="checked==2" style="width: 600rpx;height: 80rpx;background-color: #F54319;border-radius: 40rpx;text-align: center;line-height: 80rpx;color: #fff;margin: 20rpx 0;" @click="goUpload()">
				签署合同
			</view>
			<view v-if="checked==0"style="width: 600rpx;height: 80rpx;background-color: #999;border-radius: 40rpx;text-align: center;line-height: 80rpx;color: #fff;margin: 20rpx 0;" >
				等待签署
			</view>
			<view v-if="checked==1" style="width: 600rpx;height: 80rpx;background-color: deepskyblue;border-radius: 40rpx;text-align: center;line-height: 80rpx;color: #fff;margin: 20rpx 0;" >
				已签署
			</view>
		</view>
	</view>
</template>

<script>
	import {getRecommen,login,searchPlugsDataById,getUserSubmitFormDataList} from '../../../utils/api.js'
	export default {
		data() {
			return {
				info:{},
				name:'',
				nowBusinessInfo:{},
				checked:2,
				srcimage:'',
				cateName:''
			}
		},
		onLoad(options) {
			this.info=JSON.parse(decodeURIComponent(options.info))  //表单数据
			this.name=JSON.parse(decodeURIComponent(options.name))  //宠物数据
			this.cateName=options.cateName
			console.log(this.name);
		},
		onShow() {
			this.nowBusinessInfo = uni.getStorageSync('nowBusinessInfo');
			this.getFormDataList()
			this.goPath()
		},
		methods: {
			
			getFormDataList() {
				let data = {
					page:1
				};
				getUserSubmitFormDataList(data).then(res => {
					if (res.code == 200) {
						this.formDataList = res.body.list;
						this.formDataList.forEach(((item,index)=>{
							item.dataJson=JSON.parse(item.dataJson)
							
						}))
						let arr1=[]
						arr1 = this.formDataList.filter(itm => itm.dataJson.dataId == this.name.id);
						if(arr1.length>0&&arr1[0].dataJson.status==0){
							this.checked=0
						}else if(arr1.length>0&&arr1[0].dataJson.status==1){
							this.checked=1
						}else{
							this.checked=2
						}
					}
				});
			},
			goPath(){
				if(this.name.jsonViewData.filterCriteria=='猫'){
					let data = {
						businessId: this.nowBusinessInfo.jsonViewData.businessId.toString(),
						
					};
					getRecommen(data).then(res => {
						if (res.code == 200) {
							// this.carouselList = res.body
							let arr1 = [];
							arr1 = res.body.filter(itm => itm.type === 'hetong_mao');
							console.log(arr1);
							this.srcimage=arr1[0].detailsImgAndPageUrl
							// wx.downloadFile({
							// 	url:arr1[0].detailsImgAndPageUrl,
							// 	success: function(res) {
							// 		if (res.statusCode === 200) { //成功
							// 			var Path = res.tempFilePath //返回的文件临时地址，用于后面打开本地预览所用
							// 			wx.openDocument({
							// 				filePath: Path, //要打开的文件路径
							// 				success: function(res) {
							// 					console.log('打开PDF成功');
							// 				}
							// 			})
							// 		}
							// 	},
							// 	fail: function(res) {
							// 		console.log(res);
							// 	}
							// })
						}
					});
				}else if(this.name.jsonViewData.filterCriteria=='狗'){
					let data = {
						businessId: this.nowBusinessInfo.jsonViewData.businessId.toString(),
						
					};
					getRecommen(data).then(res => {
						if (res.code == 200) {
							// this.carouselList = res.body
							let arr1 = [];
							arr1 = res.body.filter(itm => itm.type === 'hetong_gou');
							console.log(arr1);
							this.srcimage=arr1[0].detailsImgAndPageUrl
							// wx.downloadFile({
							// 	url:arr1[0].detailsImgAndPageUrl,
							// 	success: function(res) {
							// 		if (res.statusCode === 200) { //成功
							// 			var Path = res.tempFilePath //返回的文件临时地址，用于后面打开本地预览所用
							// 			wx.openDocument({
							// 				filePath: Path, //要打开的文件路径
							// 				success: function(res) {
							// 					console.log('打开PDF成功');
							// 				}
							// 			})
							// 		}
							// 	},
							// 	fail: function(res) {
							// 		console.log(res);
							// 	}
							// })
						}
					});
				}
					
			},
			goUpload(){
				uni.navigateTo({
					url:`/pages/index/lingyang/upload?info=${encodeURIComponent(JSON.stringify(this.info))}&name=${encodeURIComponent(JSON.stringify(this.name))}`
				})
			},
			btn(src){
				let arr=[]
				arr[0]=src
				uni.previewImage({
					current: 0,//当前预览图片url
					urls: arr,//需要预览的图片链接列表
					loop: true//是否可循环预览
				})
			}
		}
	}
</script>

<style>

</style>
